#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;
using ll = long long;
int m, n;
ll C(ll n)
{
    return n * (n - 1) * (n - 2) / 6;
}
ll gcd(ll a, ll b)
{
    return b ? gcd(b, a % b) : a;
}
int main()
{
    cin >> m >> n;
    n++, m++;
    ll res = C(n * m) - m * C(n) - n * C(m);
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            res -= 2ll * (n - i) * (m - j) * (gcd(i, j) - 1);
        }
    }
    cout << res << endl;
    return 0;
}